package com.hmz.backend.service.Impl.friend;

import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hmz.backend.entity.ChatRoom;
import com.hmz.backend.entity.User;
import com.hmz.backend.mapper.ChatRoomMapper;
import com.hmz.backend.mapper.UserMapper;
import com.hmz.backend.service.friend.GetFriendService;
import com.hmz.backend.entity.Friend;
import com.hmz.backend.mapper.FriendMapper;
import jakarta.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.LinkedList;
import java.util.List;

@Service
public class GetFriendServiceImpl  implements GetFriendService {
    @Autowired
    FriendMapper friendMapper;
    @Autowired
    UserMapper userMapper;
    @Autowired
    ChatRoomMapper chatRoomMapper;
    //获取好友用户列表和好友聊天室列表
    @Override
    public JSONObject getFriendList(int userId) {
        //获取所有的好友实体
        List<User> friendList = chatRoomMapper.getFriendUserList(userId);
        //查询好友聊天室列表
        List<ChatRoom> friendChatRoomList = chatRoomMapper.getFriendChatRoomList(userId);
        return new JSONObject().set("message","查询成功").set("list",friendList).set("chatRooms",friendChatRoomList);
    }

}
